<%--
  Created by IntelliJ IDEA.
  User: 檬zhu
  Date: 2021/12/15
  Time: 16:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
    <title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/layui/css/layui.css">
</head>
<body>
<%
    if (request.getAttribute("addSuccess") != null) {
        out.println("<script language='JavaScript'>alert('添加成功');window.location.href='/merchant/addCategoryPage'</script>");
        return;
    }
%>
<jsp:include page="title.jsp"/>
<form class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/merchant/addCategory" method="post"
      style="margin-left:10%;">
    <div class="layui-form-item">
        <label class="layui-form-label">分类名称</label>
        <div class="layui-input-inline">
            <input type="text" name="name" lay-verify="title"
                   placeholder="请输入分类名称" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block" style="margin-left: 0">
            <button type="submit" class="layui-btn" data-type="content" lay-submit="">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="../../resources/layui/layui.js"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form, layer = layui.layer, $ = layui.jquery;
        //自定义验证规则
        form.verify({
            title: function (value) {
                if (value.length < 2) {
                    return '分类名称至少得2个字符';
                } else if (value.length > 10) {
                    return '分类名称不能大于10个字符';
                }
            }
        });
    });
</script>
</body>
</html>
